<template>
  <div class="select-tab">
    <span :class="{selected: selidx===index, 'disabled': item.disabled}" class="select-tab-item" @click="handleDeal(item,index)"
      v-for="(item,index) in tabarr" :key="index">{{item.text}}</span>
  </div>
</template>

<script>
export default {
  data() {
    return {
      selidx: 0
    }
  },
  props: {
    tabarr: {
      type: Array,
      default() {
        return []
      },
      required: true
    }
  },
  methods: {
    changeIndex(i) {
      if (typeof i === 'number' && i < this.tabarr.length) {
        this.selidx = 1
        this.$emit('selectData', this.tabarr[i])
      }
    },
    handleDeal(data, idx) {
      if (data.disabled) {
        return
      }
      this.selidx = idx
      this.$emit('selectData', data)
    }
  }
}
</script>

<style lang="scss">
.select-tab{
  display: flex;
  flex-flow: row nowrap;
  align-items: center;
  justify-content: flex-start;
  height: 76px;
  line-height: 80px;
  .select-tab-item{
    font-size:16px;
    font-weight:400;
    color:rgba(42,44,47,1);
    text-align: center;
    display: block;
    width:100px;
    height:36px;
    line-height: 36px;
    cursor: pointer;
  }
  .select-tab-item{
    &.selected {
      width:100px;
      height:36px;
      background:rgba(75,121,254,1);
      border-radius:24px;
      color:rgba(255,255,255,1);
    }
    &.disabled {
      width:100px;
      height:36px;
      background:transparent;
      border-radius:24px;
      color:#ccc;
      cursor: not-allowed;
    }
  }
}
</style>
